﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using System.Linq;
using System.Text;

namespace Snowdreamist.ComponentModel.Plugin
{
    public class ContractMetadata
    {
        public ContractMetadata(
            Guid importedIdentity,
            string name,
            Type importType,
            CandidateMode candidateMode,
            Type owner
            )
        {
            this.ImportIdentity = importedIdentity;
            this.Name = name;
            this.ImportType = importType;
            this.CandidateMode = candidateMode;
            this.Owner = owner;
            // only instance share is supported at present
            this.ShareMode = PluginShareMode.Instance;
        }

        public Guid ImportIdentity { get; private set; }

        public string Name { get; private set; }

        public Type ImportType { get; private set; }

        public CandidateMode CandidateMode { get; private set; }

        public Type Owner { get; private set; }

        public PluginShareMode ShareMode { get; private set; }

        /// <summary>
        /// Check if this metadata is available
        /// </summary>
        /// <typeparam name="T">Imported Type</typeparam>
        /// <returns></returns>
        public virtual bool IsAvailable<T>()
        {
            return true;
        }
    }
}